import java.util.*;
/**
 * @author LKQ
 * @date 2022/2/28 13:20
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        String[] words1 = {"leetcode","is","amazing","as","is"};
        String[] words2 = {"amazing","leetcode","is"};
        solution.countWords(words1, words2);
    }
    public int countWords(String[] words1, String[] words2) {
        Map<String, Integer> map1 = new HashMap<>();
        Map<String, Integer> map2 = new HashMap<>();
        for(String word: words1) {
            map1.put(word, map1.getOrDefault(word, 0) + 1);
        }
        for (String word: words2) {
            map2.put(word, map2.getOrDefault(word, 0) + 1);
        }
        int res = 0;
        for (String word: words1) {
            if (map1.get(word) == 1 && map2.getOrDefault(word, 0) == 1) {
                res++;
            }
        }
        for (String word: words2) {
            if (map2.get(word) == 1 && map1.getOrDefault(word, 0) == 1) {
                res++;
            }
        }
        return res / 2;
    }
}
